import { type baseTreeInfo } from '@/page/types/base/baseTree'
import { FormInstance } from 'element-plus/es'
export interface menuDataInfo {
  username: string
  password: string
  type: string
  wxCode: string
  id: string
  pid: string | null
  children: menuDataInfo[]
  name: string
  permission: string
  backUrl: string
  multiUrl: string
  orderNum: number
  icon: string
  frame: string
  menuType: { name: string; desc: string }
  display: boolean
  createTime: string
}

export interface menuEditInfo {
  username: string
  password: string
  type: string
  wxCode: string
  id: string | null
  pid: string | null
  children: menuDataInfo[]
  name: string
  permission: string
  backUrl: string
  multiUrl: string
  orderNum: number
  icon: string
  frame: string
  menuType: {}
  display: boolean
  createTime: string
}

export class menuClass {
  menuTable = [] as menuDataInfo[]
  dialogFormVisible = false
  addMenuTab = 'M'
  selectMenuM = [] as baseTreeInfo[]
  selectMenuC = [] as baseTreeInfo[]
  icons = [] as string[]
  isTags = true
  menuFormData: menuDataInfo = {
    username: '',
    password: '',
    type: '',
    wxCode: '',
    id: '',
    pid: null,
    children: [],
    name: '',
    permission: '',
    backUrl: '',
    multiUrl: '',
    orderNum: 0,
    icon: '',
    frame: '',
    menuType: {
      name: '',
      desc: ''
    },
    display: false,
    createTime: ''
  }

  menuSData: menuDataInfo = {
    username: '',
    password: '',
    type: '',
    wxCode: '',
    id: '',
    pid: null,
    children: [],
    name: '',
    permission: '',
    backUrl: '',
    multiUrl: '',
    orderNum: 0,
    icon: '',
    frame: '',
    menuType: {
      name: '',
      desc: ''
    },
    display: false,
    createTime: ''
  }

  addMenuData: menuEditInfo = {
    username: '',
    password: '',
    type: '',
    wxCode: '',
    id: '',
    pid: null,
    children: [],
    name: '',
    permission: '',
    backUrl: '',
    multiUrl: '',
    orderNum: 0,
    icon: '',
    frame: '',
    menuType: '',
    display: false,
    createTime: ''
  }

  rulesM = {
    name: [
      {
        required: true,
        message: '目录名称不能为空',
        trigger: 'blur'
      }
    ],
    icon: [
      {
        required: true,
        message: '图标不能为空',
        trigger: 'blur'
      }
    ],
    multiUrl: [
      {
        required: true,
        message: '前端路由不能为空',
        trigger: 'blur'
      }
    ],
    permission: [
      {
        required: true,
        message: '权限标识不能为空',
        trigger: 'blur'
      }
    ],
    orderNum: [
      {
        required: true,
        message: '排队不能为空',
        trigger: 'blur'
      }
    ]
  }

  rulesC = {
    pid: [
      {
        required: true,
        message: '目录不能为空',
        trigger: 'blur'
      }
    ],
    name: [
      {
        required: true,
        message: '菜单名称不能为空',
        trigger: 'blur'
      }
    ],
    icon: [
      {
        required: true,
        message: '图标不能为空',
        trigger: 'blur'
      }
    ],
    multiUrl: [
      {
        required: true,
        message: '前端路由不能为空',
        trigger: 'blur'
      }
    ],
    permission: [
      {
        required: true,
        message: '权限标识不能为空',
        trigger: 'blur'
      }
    ],
    orderNum: [
      {
        required: true,
        message: '排队不能为空',
        trigger: 'blur'
      }
    ]
  }

  rulesF = {
    pid: [
      {
        required: true,
        message: '菜单不能为空',
        trigger: 'blur'
      }
    ],
    name: [
      {
        required: true,
        message: '按钮名称不能为空',
        trigger: 'blur'
      }
    ],
    icon: [
      {
        required: true,
        message: '图标不能为空',
        trigger: 'blur'
      }
    ],
    backUrl: [
      {
        required: true,
        message: '前端路由不能为空',
        trigger: 'blur'
      }
    ],
    permission: [
      {
        required: true,
        message: '权限标识不能为空',
        trigger: 'blur'
      }
    ],
    orderNum: [
      {
        required: true,
        message: '排队不能为空',
        trigger: 'blur'
      }
    ]
  }

  rulesW = {
    name: [
      {
        required: true,
        message: '外链名称不能为空',
        trigger: 'blur'
      }
    ],
    icon: [
      {
        required: true,
        message: '图标不能为空',
        trigger: 'blur'
      }
    ],
    multiUrl: [
      {
        required: true,
        message: '路径不能为空',
        trigger: 'blur'
      }
    ],
    permission: [
      {
        required: true,
        message: '权限标识不能为空',
        trigger: 'blur'
      }
    ],
    orderNum: [
      {
        required: true,
        message: '排队不能为空',
        trigger: 'blur'
      }
    ]
  }

  menuTypes = [
    {
      value: 'M',
      label: '目录'
    },
    {
      value: 'C',
      label: '菜单'
    },
    {
      value: 'F',
      label: '按钮'
    }
  ]
}
